package Prefix_and;

import java.util.Scanner;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-01-23
 * Time:20:55
 * Text：寻找数组的中心下标
 */
public class Text3 {
    public int pivotIndex(int[] nums) {
        int size=nums.length;
        int[] array=new int[size+2];
        int count=0;
        for(int i=1;i<size+1;i++){
            array[i]=nums[i-1];
            count+=array[i];
        }
        int[] arr2=new int[size+2];
        arr2[1]=count-array[1];
        for(int i=1;i<size+1;i++){
            arr2[i+1]=arr2[i]-array[i]-array[i+1];
            if(arr2[i]==0){
                return i-1;
            }
        }
        return -1;
    }
    public static void main(String[] args) {

    }
}
